{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">添加车辆</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="{:url('bus/handle')}" lay-filter="component-form-group">
                <div class="layui-form-item">
                    <label class="layui-form-label">所属车队</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$info->business->name|default=''}" disabled autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车牌号码</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$info.bus_no|default=''}" disabled autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">座位数</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$info.seat_num|default=''}" disabled autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">运营时间</label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$info.begin_time|default=''}" disabled id="begin_time" name="begin_time" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">车辆品牌</label>
                    <div class="layui-input-inline">
                        <select name="brand_id" disabled>
                            <option value="">请选择车辆品牌</option>
                            {foreach $brand_list as $key=>$val}
                            <option value="{$val.id}" {if $info.brand_id == $val.id}selected{/if} >{$val.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">行驶证</label>
                    <div class="layui-input-block">
                        <div class="layui-upload-list" id="license_view">
                            <img class="layui-upload-img" id="driving_license_img" src="{$info->driving_license |default=''}">
                            <p id="test-upload-demoText"></p>
                        </div>
                    </div>
                </div>
                <style>

                    .layui-col-xs3 {
                        width: auto;
                    }

                    img {
                        width: 92px;
                        /*height: 92px;*/
                        margin: 0 10px 10px 0;
                        border: 1px solid #e6e6e6;
                    }
                </style>
                <div class="layui-form-item">
                    <label class="layui-form-label">车辆实拍</label>
                    <div class="layui-input-block">
                        <div class="layui-upload">
                            <input class="layui-upload-file" type="file" accept="undefined" name="file" multiple="">
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                <div class="layui-upload-list">
                                    <div class="layui-row" id="pic-list">
                                        {if count($info->imgs) > 0}
                                        {foreach $info->imgs as $key=>$val}
                                        <div class="layui-col-xs3">
                                            <img src="{$val->img}" class="layui-upload-img" data-src="{$val->getData('img')}">
                                            <p id="demoText">
                                                <button type="button" class="layui-btn layui-btn-xs demo-reload">
                                                    删除
                                                </button>
                                            </p>
                                        </div>
                                        {/foreach}
                                        {/if}
                                    </div>
                                </div>
                            </blockquote>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <input type="radio" checked title="{$info->state}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">操作</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="state" value="2" checked title="通过">
                        <input type="radio" name="state" value="3" title="不通过">
                    </div>
                </div>
                {:token()}
                <input type="hidden" value="{$act}" name="act" />
                <input type="hidden" value="{$info['id']|default=''}" name="id" />
                <div class="layui-form-item layui-hide">
                    <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
                </div>
                <!--<div class="layui-form-item layui-layout-admin">-->
                <!--<div class="layui-input-block">-->
                <!--<div class="layui-footer" style="left: 0;">-->
                <!--<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>-->
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                <!--</div>-->
                <!--</div>-->
                <!--</div>-->
            </form>
        </div>
    </div>
</div>


<script>
    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'upload'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form
            ,upload = layui.upload;

        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#begin_time'
            ,type: 'date'
        });

        $('#pic-list').viewer();
        $("#license_view").viewer();

        $(".demo-reload").click(function () {
            $(this).parents('.layui-col-xs3').remove();//模拟前端删除按钮
            var img_urls = [];
            $(".layui-upload-img").each(function () {
                img_urls.push($(this).attr("data-src"));
            });
            $("#img_url").val(img_urls);
        });

        form.render(null, 'component-form-group');

    });

    function openImg(i) {
        layer.photos({
            photos: '#pic-list'
        });
    }
</script>
{/block}